import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class test11 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // 数组个数
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
        }
        System.out.println(longestConsecutive(nums));
    }
    public static int longestConsecutive(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        Arrays.sort(nums); // 排序

        int maxCount = 0;
        int flag = 0;
        for (int i = 1; i < nums.length; i++) {
            if(nums[i]-nums[i-1]==1) {
                flag++;
                continue;
            }
            if (nums[i] == nums[i-1])
                continue;
            if(maxCount<flag)
                maxCount = flag;
            flag = 0; //从新开始计算
        }
        if(maxCount<flag)
            maxCount = flag;
        maxCount++;
        return maxCount;
    }
}
